﻿#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;

//@file   : null
//@author : Chizuru
//@date   : 2024/4/1
//@brief  : null



void function1_1() {
	float math, Chinese, English;
	scanf("%f%f%f", &math, &Chinese, &English);
	printf("%.2f", (math + Chinese + English) / 3);
}

void function1_2() {
	float a;
	scanf("%f", &a);
	printf("%.1f\%%", a * 100);
}

void function2() {
	char s[1000];
	scanf("%s", s);
	int i = 0;
	int num = 0, ch = 0;
	while (s[i]) {
		if (s[i] >= '0' && s[i] <= '9') {
			num++;
		}
		else {
			ch++;
		}
		i++;
	}
	printf("数字:%d,字母:%d", num, ch);

}
void function3() {
	int grade;
	scanf("%d", &grade);
	if (grade < 0 || grade >100) {
		printf("ERROR");
		return;
	}

	grade /= 10;
	char c;
	switch (grade) {
	case  9:
		c = 'A';
		break;
	case  8:
		c = 'B';
		break;
	case  7:
		c = 'C';
		break;
	case  6:
		c = 'D';
		break;
	case  10:
		c = 'A';
		break;
	default:
		c = 'F';
		break;
	}
	printf("%c", c);

}

void function4() {
	for (int i = 100; i < 1000; i++) {
		int num = i;
		int x = num % 10;
		int y = num / 10 % 10;
		int z = num / 100;

		if (num == x * x * x + y * y * y + z * z * z) {
			printf("%d\n", num);
		}
	}
}
/*
当i等于0时，while的count不会累加，for的count不会累加

*/

typedef struct {
	float money;
}Person;

void erase(Person* p) {
	p->money = 0;
}
void show(Person* p) {
	printf("%.2f\n", p->money);
}
void save(Person* p) {
	printf("请输入存款金额:");
	int m;
	scanf("%d", &m);
	if (m < 0) {
		printf("失败");
		return;
	}
	p->money += m;
	printf("成功存款%.2f元", m);
}
void draw(Person* p) {
	printf("请输入取款金额:");
	int m;
	scanf("%d", &m);
	if (m > p->money || m < 0) {
		printf("失败");
		return;
	}
	p->money -= m;
	printf("成功取款%.2f元", m);
}
void function6() {
	Person p;
	p.money = 0;
	int i;
	printf("==============\n0 清空账户余额\n1 往账户上存钱\n2 从账户上取钱\n3 显示当前余额\n4退出程序。\n请选择操作(0-4):");

	while (scanf("%d", &i) && i != 4) {
		//cout << i;
		switch (i) {
		case 0:
			erase(&p);
			break;
		case 1:
			save(&p);
			break;
		case 2:
			draw(&p);
			break;
		case 3:
			show(&p);
			break;
		}
		printf("==============\n0 清空账户余额\n1 往账户上存钱\n2 从账户上取钱\n3 显示当前余额\n4退出程序。\n请选择操作(0-4):");
	}
	printf("已退出");
}


/**
x&(-x)：保留二进制下最后出现的1的位置，其余位置置0（即一个数中最大的2的n次幂的因数
x&(x-1)：消除二进制下最后出现1的位置，其余保持不变
**/

void fun7_1(int a) {
	if (a % 2) {
		printf("奇数");
	}
	else {
		printf("偶数");
	}
}
void fun7_2(int x) {
	if (x & (x - 1)) {
		printf("不是2的幂");
	}
	else {
		printf("是2的幂");
	}
}
int fun7_3(int a) {
	return a & (-a);
}

// 0 ^ a = a
void swap7_4(int a, int b) {
	int x = a;
	int y = b;
	x = x ^ y;
	y = y ^ x;
	x = x ^ y;
	printf("x=%d,y=%d", x, y);
}

int fun7_5(int nums[], int n) {
	int t = 0;
	for (int i = 0; i < n; i++) {
		t ^= nums[i];
	}
	return t;
}


void fun7_6(int nums[], int n) {
	int* hash = (int*)malloc(sizeof(int) * n);
	memset(hash, 0, sizeof(hash) * n);

	for (int i = 0; i < n; i++) {
		hash[nums[i]]++;
	}
	for (int i = 0; i < n; i++) {
		if (hash[i] == 1) {
			printf("%d\n", i);
		}
	}

}



//最大公因数
int gcd(int a, int b) {
	int c;
	while (b) {
		c = a % b;
		a = b;
		b = c;
	}
	return a;
}
void fun8() {
	typedef struct {
		int m;//分子
		int n;//分母
	}Number;

	Number num1, num2, num3;

	printf("Enter first fraction:");
	scanf("%d/%d", &num1.m, &num1.n);

	printf("Enter second fraction:");
	scanf("%d/%d", &num2.m, &num2.n);

	num3.m = num1.m * num2.n + num2.m * num1.n;
	num3.n = num1.n * num2.n;


	int w = gcd(num3.m, num3.n);
	printf("The sum is %d/%d", num3.m / w, num3.n / w);

}


//9
/*
c = ((x & MASK) == 0);
0

z = ((x++) + (++y ∗ 2));
16

y >>= ((x & 0x2) && z);
2
*/

/*
double ans = 10.0 + 2.0 / ((3.0 - 2.0) * 2.0);

*/

//#define SQUARED(x) x*x
//#define SQUARED(x) (x*x)
//#define SQUARED(x) (x)*(x)
#define SQUARED(x) ((x)*(x))

double ans = 18.0 / SQUARED(2 + 1);
//12
//3.6
//18
//2
/*
int function(int arg1) {
	return arg1 - 1;
}
#define MESSAGE "Happy new year!"
*/




int main(void) {
	
	double ans = 10.0 + 2.0 / ((3.0 - 2.0) * 2.0);
	
	printf("%lf", ans);
	return 0;

}